<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/11/13
  Time: 19:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增管理员</title>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
    <style type="text/css" rel="stylesheet">
        body{
            font-family: "楷体";
            font-size: 16px;
        }
        .clearfix:after{
            content: "";
            clear: both;
            display: block;
        }
        .all{
            width: 1100px;
            max-height: 450px;
            overflow: auto;
            border: 2px solid rgb(97,166,0);
            margin: 0 auto;
            padding: 50px 30px;
            box-sizing: border-box;
        }
        .yheader{
            font-size: 18px;
            font-weight: 600;
            color: rgb(97,166,0);
            margin-bottom: 10px;
        }
        .form{
            width: 700px;
            margin: 0 auto;
            padding-top: 10px;
        }
        .form .list{
            width: 500px;
            height: 30px;
            margin: 0 auto;
            border: 2px solid black;
            box-sizing: border-box;
            margin-bottom: 10px;
        }
        .form .list .everylist{
            float: left;
            width: 100px;
            height: 100%;
            line-height: 30px;
            text-align: center;
            font-weight: 600;
            border-right: 1px solid black;
        }
        .form .list .input{
            font-weight: 500;
            width: 300px;
            height: 100%;
            line-height: 30px;
            text-align: left;
            padding-left: 10px;
            box-sizing: border-box;
            border: none;
        }
        #btn{
            width: 80%;
            height: 28px;
            line-height: 30px;
            background: #4aa3d6;
            color: #fff;
            font-weight: 700;
            font-size: 18px;
            display: block;
            margin: 0 auto;
            border: none;
            border-radius: 30px;
            cursor: pointer;
        }
        #btn:hover{
            background: rgb(97,166,0);
        }
        .form .message{
            text-align: center;
            font-weight: 700;
            font-size: 18px;
            line-height: 30px;
            color: red;
        }
        .form .mes{
            border: none;
        }
    </style>
</head>
<body>
    <article class="all">
         <div class="yheader">当前位置&nbsp;&gt;&gt;&nbsp;添加普通管理员</div>
         <div class="form">
             <div class="list">
                 <div class="everylist uname">
                     用户名
                 </div>
                 <input type="text" class="everylist username input" placeholder="请输入用户名">
             </div>
             <div class="list">
                 <div class="everylist pass">
                     密码
                 </div>
                 <input type="password" class="everylist password input" placeholder="请输入密码">
             </div>
             <div class="list">
                 <div class="everylist emai">
                     邮箱地址
                 </div>
                 <input type="text" class="everylist email input" placeholder="请输入邮箱地址">
             </div>
             <div class="list button mes">
                 <button type="button" id="btn" class="btn">添加</button>
             </div>
             <div class="list message mes">

             </div>
         </div>
    </article>
<script>
    $(document).ready(function () {
        var reg = /^[0-9a-zA-Z]+@+[0-9a-zA-Z]+\.com(\.cn)?$/;
        var yanzheng = function(){
            var email = $.trim($(".email").val());
            if($(".username").val() == ""){
                $(".message").html("用户名不能为空！");
            }else if($(".password").val() == ""){
                $(".message").html("密码不能为空！");
            }else if(email ==""){
                $(".message").html("邮箱不能为空！");
            }else if(!reg.test(email)){
                $(".message").html("邮箱格式不正确！");
            }else{
               var uname = $.trim($(".username").val());
               var pass =$.trim($(".password").val());
               var emai = $.trim($(".email").val());
               var data = "uname="+uname+"&pass="+pass+"&emai="+emai;
               $.ajax({
                   url:"/SuperAdminServlet",
                   data:"type=add&"+data,
                   type:"post",
                   dataType:"text",
                   async:true,
                   success:function (data) {
                       if(data == "1"){
                           alert("添加成功！");
                           window.location.href="/SuperAdminServlet?type=alladmin";
                       }else{
                           alert("添加失败！");
                       }
                   },
                   error:function (error) {
                       alert("系统异常，请稍后重试")
                   }
               })
            }
        }
         $(".input").focus(function () {
              $(this).parent(".list").css({"border":"2px solid rgb(97,166,0)"});
         }).blur(function () {
             $(this).parent(".list").css({"border":"2px solid black"});
         })
        $("#btn").click(function () {
             yanzheng();
        })

    })
</script>
</body>
</html>

